import React from 'react'
import PropTypes from 'prop-types'
import Component, { mapStateToProps, mapDispatchToProps } from '@components/Component'
import { Alert } from 'antd'
import { connect } from 'react-redux'
import DefaultFormCourt from './FormCourt/FormCourt'

class FormCourt extends Component {
  state = {

  }

  render () {
    const { caseDetail, refreshCaseData, editable } = this.props
    if (!caseDetail) {
      return null
    }
    if (!caseDetail.accept_structure) {
      return <Alert message='收案机构不存在' type='error' showIcon />
    }
    if (caseDetail.accept_structure === '本会') {
      return (<DefaultFormCourt caseDetail={caseDetail} refreshCaseData={refreshCaseData} editable={editable} />)
    }
    return <div />
  }
}

FormCourt.propTypes = {
  caseDetail: PropTypes.object,
  refreshCaseData: PropTypes.func,
  editable: PropTypes.bool
}
FormCourt.defaultProps = {
  caseDetail: {},
  refreshCaseData: () => {},
  editable: false
}

const mapState = mapStateToProps(function (state) {
  return {
    userInfo: state.basic.userInfo
  }
})

const mapDispatch = mapDispatchToProps(function (dispatch) {
  return {

  }
})

export default connect(mapState, mapDispatch)(FormCourt)
